package com.ddtech.business.course.controller;

import com.ddtech.business.course.entity.CourseStudyRecordDetails;
import com.ddtech.business.course.query.CourseStudyRecordDetailsQuery;
import com.ddtech.business.course.service.CourseStudyRecordDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @version v1.0
 * @ClassName:CourseStudyRecordDetailsController description：
 * @author:wei_zhang(xiao)
 * @date: 2023-06-08 13:42
 */
@Api(tags = "业务-课程学习进度详情，视频定位")
@RestController
@RequestMapping("/course/study-record-details")
public class CourseStudyRecordDetailsController {


    @Autowired
    private CourseStudyRecordDetailsService courseStudyRecordDetailsService;


    @ApiOperation(value = "查询当前课程个人当前学习到哪里")
    @GetMapping(value = "/personInfo")
    public ResponseEntity getPersonInfo(CourseStudyRecordDetailsQuery courseStudyRecordDetailsQuery) {
        return new ResponseEntity(courseStudyRecordDetailsService.personInfo(courseStudyRecordDetailsQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "保存当前课程个人当前学习进度，视频定位")
    @PostMapping(value = "/create")
    public ResponseEntity create(@Validated @RequestBody CourseStudyRecordDetails courseStudyRecordDetails) {
        courseStudyRecordDetailsService.create(courseStudyRecordDetails);
        return new ResponseEntity(true,HttpStatus.OK);
    }

    @ApiOperation(value = "消防培训-保存当前课程个人当前学习进度，课程定位")
    @PostMapping(value = "/createXf")
    public ResponseEntity createXf(@Validated @RequestBody CourseStudyRecordDetails courseStudyRecordDetails) {
        courseStudyRecordDetailsService.createXf(courseStudyRecordDetails);
        return new ResponseEntity(true,HttpStatus.OK);
    }

    @ApiOperation(value = "保存培训课程个人当前学习进度，视频定位")
    @PostMapping(value = "/trainCreate")
    public ResponseEntity trainCreate(@Validated @RequestBody CourseStudyRecordDetails courseStudyRecordDetails) {
        courseStudyRecordDetailsService.trainCreate(courseStudyRecordDetails);
        return new ResponseEntity(true,HttpStatus.OK);
    }

    @ApiOperation(value = "PC、移动端app查询个人学习历史")
    @GetMapping(value = "/history")
    public ResponseEntity getPersonStudyHistory(CourseStudyRecordDetailsQuery courseStudyRecordDetailsQuery) {
        return new ResponseEntity(courseStudyRecordDetailsService.personStudyHistory(courseStudyRecordDetailsQuery),HttpStatus.OK);
    }

    @ApiOperation(value = "PC、移动端app查询个人课程学习总体进度百分比")
    @GetMapping(value = "/study-percent")
    public ResponseEntity personCourseStudyPercent(CourseStudyRecordDetailsQuery courseStudyRecordDetailsQuery) {
        return new ResponseEntity(courseStudyRecordDetailsService.personCourseStudyPercent(courseStudyRecordDetailsQuery),HttpStatus.OK);
    }

    @ApiOperation(value = "PC、移动端app查询个人培训课程学习总体进度百分比")
    @GetMapping(value = "/train-study-percent")
    public ResponseEntity personTrainStudyPercent(CourseStudyRecordDetailsQuery courseStudyRecordDetailsQuery) {
        return new ResponseEntity(courseStudyRecordDetailsService.personTrainStudyPercent(courseStudyRecordDetailsQuery),HttpStatus.OK);
    }

    @ApiOperation(value = "移动端app-课程首页统计数据")
    @GetMapping(value = "/course-study-statistic-app")
    public ResponseEntity courseStudyStatisticApp() {
        return new ResponseEntity(courseStudyRecordDetailsService.courseStusyStatisticApp(),HttpStatus.OK);
    }

    @ApiOperation(value = "管理端首页统计数据-员工学习情况")
    @GetMapping(value = "/study-statistic-index")
    public ResponseEntity studyStatisticIndex() {
        return new ResponseEntity(courseStudyRecordDetailsService.studyStatisticIndex(),HttpStatus.OK);
    }

    @ApiOperation(value = "管理端首页统计数据-员工学习TOP10")
    @GetMapping(value = "/study-statistic-top10")
    public ResponseEntity studyStatisticTop10() {
        return new ResponseEntity(courseStudyRecordDetailsService.studyStatisticTop10(),HttpStatus.OK);
    }

    @ApiOperation(value = "管理端首页统计数据-课程分类统计")
    @GetMapping(value = "/course-type-statistic")
    public ResponseEntity courseTypeStatistic() {
        return new ResponseEntity(courseStudyRecordDetailsService.courseTypeStatistic(),HttpStatus.OK);
    }

    @ApiOperation(value = "管理端首页统计数据-今日学习人数、学习时间、人均学习时间")
    @GetMapping(value = "/today-study-info")
    public ResponseEntity todayStudyInfo() {
        return new ResponseEntity(courseStudyRecordDetailsService.todayStudyInfo(),HttpStatus.OK);
    }
}
